package com.lineage.server.clientpackets;

import com.lineage.echo.ClientExecutor;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.serverpackets.S_ServerMessage;
import com.lineage.server.serverpackets.ServerBasePacket;
import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class C_BanParty extends ClientBasePacket {
  private static final Log _log = LogFactory.getLog(C_BanParty.class);
  
  public void start(byte[] decrypt, ClientExecutor client) {
    try {
      read(decrypt);
      L1PcInstance pc = client.getActiveChar();
      if (!pc.getParty().isLeader(pc))
        pc.sendPackets((ServerBasePacket)new S_ServerMessage(427)); 
      if (pc.getMapId() == 9000 || pc.getMapId() == 9101)
        return; 
      String userName = readS();
      ConcurrentHashMap pcs = pc.getParty().partyUsers();
      if (pcs.isEmpty())
        return; 
      if (pcs.size() <= 0)
        return; 
      Iterator<L1PcInstance> iter = pcs.values().iterator();
      while (iter.hasNext()) {
        L1PcInstance member = iter.next();
        String memberName = member.getName().toLowerCase();
        if (memberName.equals(userName.toLowerCase())) {
          pc.getParty().kickMember(member);
          return;
        } 
      } 
      pc.sendPackets((ServerBasePacket)new S_ServerMessage(426, userName));
    } catch (Exception exception) {
    
    } finally {
      over();
    } 
  }
  
  public String getType() {
    return getClass().getSimpleName();
  }
}
